<link rel="stylesheet" href="__STATIC_LIB__layuiadmin/layui/layui_ext/dtree/dtree.css">
<link rel="stylesheet" href="__STATIC_LIB__layuiadmin/layui/layui_ext/dtree/font/dtreefont.css">

<form class="layui-form  seller-alone-form" id="userEdit" style="padding: 20px;">
    
    <div class="layui-form-item">
        <input type="hidden" name="id" value="{$bookInfo.id}">
        <div class="layui-inline">
            <label class="layui-form-label">年度：</label> 
            <div class="layui-input-inline">
                <input type="text" name="plan_year" style="color:#C0C4CC" disabled="true" Readonly="true" class="layui-input" value="{$bookInfo.plan_year}"> 
            </div>
        </div> 
        <div class="layui-inline">
            <label class="layui-form-label">季度：</label>
            <div class="layui-input-inline">
                <input type="text" name="plan_season" style="color:#C0C4CC" disabled="true" Readonly="true" class="layui-input" value="{$bookInfo.plan_season}">
            </div>
        </div>
    </div> 
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">部/院：</label> 
            <div class="layui-input-inline">
                <input type="text" name="dept_name" style="color:#C0C4CC" disabled="true" Readonly="true" class="layui-input" value="{$bookInfo.dept_name}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">专业：</label> 
            <div class="layui-input-inline">
                <input type="text" name="specialty_name" style="color:#C0C4CC" disabled="true" Readonly="true" class="layui-input" value="{$bookInfo.specialty_name}">
            </div>
        </div>
    </div> 
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">班级：</label>
            <div class="layui-input-inline">
                <input type="text" name="plan_class_name" style="color:#C0C4CC" disabled="true" Readonly="true" class="layui-input" value="{$bookInfo.plan_class_name}">
            </div>
        </div> 
        <div class="layui-inline">
            <label class="layui-form-label">方向：</label>
            <div class="layui-input-inline">
                <input type="text" name="plan_dir" style="color:#C0C4CC" disabled="true" Readonly="true" class="layui-input" value="{$bookInfo.plan_dir}">
            </div>
        </div>
    </div>
    <div class="layui-form-item"> 
        <div class="layui-inline">
            <label class="layui-form-label">课程名称：</label>
            <div class="layui-input-inline">
                <input type="text" name="course_name" lay-verify="required" class="layui-input" value="{$bookInfo.course_name}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">教材名称：</label>
            <div class="layui-input-inline">
                <input type="text" name="book_name" style="color:#C0C4CC" disabled="true" Readonly="true" class="layui-input" value="{$bookInfo.book_name}">
            </div>
        </div>
        
    </div> 
    <div class="layui-form-item"> 
        <div class="layui-inline">
            <label class="layui-form-label">ISBN：</label>
            <div class="layui-input-inline">
                <input type="text" name="book_isbn" style="color:#C0C4CC" disabled="true" Readonly="true" class="layui-input" value="{$bookInfo.book_isbn}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">主编：</label>
            <div class="layui-input-inline">
                <input type="text" name="book_author" style="color:#C0C4CC" disabled="true" Readonly="true" class="layui-input" value="{$bookInfo.book_author}">
            </div>
        </div>
        
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">出版社：</label>
            <div class="layui-input-inline">
                <input type="text" name="book_concern" style="color:#C0C4CC" disabled="true" Readonly="true" class="layui-input" value="{$bookInfo.book_concern}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label"><i class="required-color">*</i>单价：</label>
            <div class="layui-input-inline">
                <input type="text" name="plan_price" style="color:#C0C4CC" class="layui-input"  disabled="true" Readonly="true" value="{$bookInfo.plan_price}">
            </div>
        </div>
        
    </div>
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label"><i class="required-color">*</i>教材数量：</label>
            <div class="layui-input-inline">
                <input type="text" name="plan_book_num" lay-verify="required" class="layui-input" value="{$bookInfo.plan_book_num}">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label"><i class="required-color">*</i>折扣：</label>
            <div class="layui-input-inline">
                <input type="text" name="book_disc" style="color:#C0C4CC" class="layui-input"  disabled="true" Readonly="true" value="{$bookInfo.book_disc}">
            </div>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" name="open_spec" value="0">
            {:zlserverToken()}
            <button id="user_edit_save" class="layui-btn" lay-submit="" lay-filter="save">保存</button>
        </div>
    </div>
    {:zlserverToken()}
</form>
<script>
    layui.extend({
        dtree: '__STATIC_LIB__layuiadmin/layui/layui_ext/dtree/dtree'
    }).use(['form', 'laydate', 'dtree'], function () { 
        var form = layui.form;
  
        //保存计划
        form.on('submit(save)', function (data) {
            formData = data.field;
            if (!formData) {
                layer.msg('请先完善数据', { time: 1300 });
                return false;
            }

            // 判断单价：
            // if(formData.plan_price <= 0) {
            //     layer.msg('请输入合法的单价', { time: 1300 });
            //     return false;
            // }
            if(formData.plan_book_num <= 0) {
                layer.msg('请输入合法的数量', { time: 1300 });
                return false;
            }
            
            $("#user_edit_save").addClass("layui-btn-disabled");
            $('#user_edit_save').attr("disabled", true);

            $.ajax({
                type: 'post',
                url: '{:url("BookPlan/edit")}',
                data: formData,
                dataType: 'json',
                success: function (e) {
                    if (e.status === true) {
                        layer.open({
                            type: 1
                            , offset: 'auto'
                            , id: 'layerDemoAuto'
                            , content: '<div style="padding: 20px 100px;">' + e.msg + '</div>'
                            , btn: '关闭'
                            , btnAlign: 'c' //按钮居中
                            , shade: 0.3 //不显示遮罩
                            , yes: function () {
                                parent.layui.admin.events.changeTabAndRefresh('/manage/book_plan/index.html', 'bookPlanTable');
                            }, close: function () {
                                console.log('close');
                            }, end: function () {
                                parent.layui.admin.events.changeTabAndRefresh('/manage/book_plan/index.html', 'bookPlanTable');
                            }
                        });
                    } else {
                        $("#user_edit_save").removeClass("layui-btn-disabled");
                        $('#user_edit_save').removeAttr("disabled");

                        layer.msg(e.msg, { time: 1300 });
                    }
                }
            });
            return false;
        });
    });
</script>